
#include "../source/serve.hpp"
void HandlerConnected(const PtrConnection &connec)
{
    // 打印一下连接的地址
    DBG_LOG("connect create:%p", connec.get());
}
void HandlerClosed(const PtrConnection &conc)
{
    DBG_LOG("connect release:%p", conc.get());
}
void HandlerMes(const PtrConnection &conc, Buffer *buffer)
{
    DBG_LOG("client say:%s", buffer->ReadPOS());
    buffer->MoveReadInd(buffer->ReadSpace());
    std::string data = "天天开心！！！";
    conc->Send(data.c_str(), data.size());
}

int main()
{
    TcpServe serve(8089);
    serve.SetThreadCount(0);
    serve.EnableInactiveRelase(10);
    serve.SetConnectedCallback(HandlerConnected);
    serve.SetMessageCallback(HandlerMes);
    serve.SetClosedCallback(HandlerClosed);
    serve.Start();
    return 0;
}